package com.project.controller;

import com.project.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("test")
public class TestController {
    @RequestMapping("showInfo")
    public String showInfo(Model model){
        //在请求对象中绑定数据
        model.addAttribute("name","张翠山");
        model.addAttribute("imgPath","1.jpg");
        model.addAttribute("userId",6);
        model.addAttribute("grade",50);
        List<UserBean> userList = List.of(
                new UserBean(1,"张三","男"),
                new UserBean(4,"何勇","男"),
                new UserBean(3,"刘庆","女"),
                new UserBean(6,"周勇","男"),
                new UserBean(8,"胡四","女")
        );
        model.addAttribute("userList", userList);
        model.addAttribute("pages",5);

        return "/html/index.html";
    }

    @RequestMapping("del")
    public void del(int id){
        System.out.println(id);
    }
}
